package com.implementsystem.prestacontas.programas.dao;

import java.util.List;

import javax.ejb.Stateless;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.implementsystem.prestacontas.geral.dao.GenericDao;
import com.implementsystem.prestacontas.programas.entity.Programa;

@Stateless
public class ProgramaDao extends GenericDao<Programa>{

	private static final long serialVersionUID = 5081201957553858049L;

	@SuppressWarnings("unchecked")
	public List<Programa> findAllOrderByDescricao(){
		Criteria criteria = getCriteria(Programa.class);
		criteria.addOrder(Order.asc("nome"));
		
		return criteria.list();
		
	}
	
	public Programa findByCodigoPrograma(String nome){
		
		Criteria criteria = getCriteria(Programa.class);
		criteria.add(Restrictions.eq("nome", nome));
		
		return (Programa)criteria.uniqueResult();
	}
	

}
